using System;

using octalforty.Waffle.ObjectModel.Business.Objects;

using octalforty.Waffle.Web.Engine.Web.UI;

namespace octalforty.Waffle.Web.UI.Views.Signup.Controls
{
    /// <summary>
    /// Signup form.
    /// </summary>
    public partial class SignupForm : UserControl
    {
        #region Private Member Variables
        private EventHandler signup;
        #endregion

        #region Public Properties
        /// <summary>
        /// Gets or sets a string which contains the first name of this <see cref="User"/>.
        /// </summary>
        public string FirstName
        {
            get { return firstNameTextBox.Text; }
            set { firstNameTextBox.Text = value; }
        }

        /// <summary>
        /// Gets or sets a string which contains the last name of this <see cref="User"/>.
        /// </summary>
        public string LastName
        {
            get { return lastNameTextBox.Text; }
            set { lastNameTextBox.Text = value; }
        }

        /// <summary>
        /// Gets or sets email address.
        /// </summary>
        public string EmailAddress
        {
            get { return emailAddressTextBox.Text; }
            set { emailAddressTextBox.Text = value; }
        }

        /// <summary>
        /// Gets or sets a string which contains the login of this <see cref="User"/>.
        /// </summary>
        public string Login
        {
            get { return loginTextBox.Text; }
            set { loginTextBox.Text = value; }
        }

        /// <summary>
        /// Gets or sets a <see cref="Byte"/> array which contains the hash of the password.
        /// </summary>
        public string Password
        {
            get { return passwordTextBox.Text; }
            set { passwordTextBox.Text = value; }
        }
        #endregion

        #region Public Events
        /// <summary>
        /// Occurs when the user clicks a "Signup" button.
        /// </summary>
        public event EventHandler Signup
        {
            add { signup += value; }
            remove { signup -= value; }
        }
        #endregion

        /// <summary>
        /// Initializes a new instance of <see cref="SignupForm"/> class.
        /// </summary>
        public SignupForm()
        {
        }

        protected void signupButton_Click(object sender, EventArgs e)
        {
            OnSignup();
        }

        private void OnSignup()
        {
            if(signup != null)
                signup(this, EventArgs.Empty);
        }
    }
}